#include <stdbool.h>
#include "board_config.h"
//#include "app_main.h"
#include "pin_config.h"
#include <devices/devicelist.h>
#include <yoc/init.h>
#include <ulog/ulog.h>
#include <yoc/atserver.h>
#include <devices/uart.h>
#include "platform.h"
#include "io_config.h"
#define TAG "init"

//#define AT_HELP {"AT+HELP", at_cmd_callback}

extern atserver_cmd_t at_cmd[];

void at_cmd_callback(char *cmd, int type, char *data) {
        char format[1026];
        atserver_scanf("%s",&format);
        LOGD(TAG,"cmd is %s",cmd);
        AT_BACK_OK();
}

static void send_atserver(char *format){
    int ret;
    ret = atserver_send("atserver send content is %s",format);
    if(ret==0){
        LOGD(TAG,"atserver send success!");
    }else{
        LOGD(TAG,"atserver send failed!");
    }
}

void board_yoc_init(void)
{
    platform_init();
    board_init();
    uart1_io_init(PB00,PB01);
    uart2_io_init(PB08,PB09);
    uart3_io_init(PA00,PA07);
    console_init(CONSOLE_IDX, 921600, 128);
    ulog_init();
    aos_set_log_level(AOS_LL_DEBUG);

    uart_config_t config;
    uart_config_default(&config);

    utask_t *task1 = utask_new("at_srv",  5000, QUEUE_MSG_COUNT, AOS_DEFAULT_APP_PRI);

    int ret = atserver_init(task1, "uart1", &config);

    if(ret == 0){
        LOGD(TAG,"atserver init success!");
    }else{
        LOGD(TAG,"atserver init failed!\n");
    }
}
